package com.fancy.util;

import com.fancy.emums.StatusEnum;
import com.fancy.vo.ResultVO;

/**
 * Created by FancyFong on 7/9/2017.
 */
public class ResultUtil {

    /**
     * 返回成功
     * @param emum
     * @param object
     * @return
     */
    public static ResultVO success(StatusEnum emum, Object object){
        ResultVO result = new ResultVO();
        result.setCode(emum.getCode());
        result.setMessage(emum.getMessage());
        result.setSuccess(true);
        result.setData(object);
        return result;
    }

    /**
     * 返回成功
     * @param emum
     * @return
     */
    public static ResultVO success(StatusEnum emum){
        ResultVO result = new ResultVO();
        result.setCode(emum.getCode());
        result.setMessage(emum.getMessage());
        result.setSuccess(true);
        return result;
    }

    /**
     * 返回错误
     * @param emum
     * @param object
     * @return
     */
    public static ResultVO error(StatusEnum emum, Object object){
        ResultVO result = new ResultVO();
        result.setCode(emum.getCode());
        result.setMessage(emum.getMessage());
        result.setSuccess(false);
        result.setData(object);
        return result;
    }

    /**
     * 返回错误
     * @param emum
     * @return
     */
    public static ResultVO error(StatusEnum emum){
        ResultVO result = new ResultVO();
        result.setCode(emum.getCode());
        result.setMessage(emum.getMessage());
        result.setSuccess(false);
        return result;
    }

}
